/*    */ package com.cr.api.controller;
/*    */ 
/*    */ import com.cr.api.model.AddBondClueModel;
/*    */ import com.cr.business.domain.CrBondClue;
/*    */ import com.cr.business.domain.CrEvidenceInfo;
/*    */ import com.cr.business.dto.CreditorRightsDto;
/*    */ import com.cr.business.service.ICrBondClueService;
/*    */ import com.cr.business.service.ICrEvidenceInfoService;
/*    */ import com.cr.common.core.controller.BaseController;
/*    */ import com.cr.common.core.domain.AjaxResult;
/*    */ import com.github.pagehelper.PageInfo;
/*    */ import java.text.SimpleDateFormat;
import java.util.Arrays;
/*    */ import java.util.Date;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
import java.util.stream.Collectors;
/*    */ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
/*    */ import org.springframework.beans.BeanUtils;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.web.bind.annotation.*;
/*    */
/*    */
/*    */

/*    */ /*    */
         @Api(description = "债权线索/交易查询")
/*    */ @RestController
/*    */ @RequestMapping({"/api/clue"})
         @CrossOrigin
/*    */ public class ApiBondClueController extends BaseController {
/*    */   @Autowired
/*    */   private ICrBondClueService crBondClueService;
/*    */   
/*    */   @Autowired
/*    */   private ICrEvidenceInfoService evidenceInfoService;
/*    */   
/*    */   @PostMapping({"/releaseClues"})
/*    */   @ResponseBody
/*     */  @ApiOperation("发布债权线索")
/*    */   public AjaxResult releaseClues(@RequestBody AddBondClueModel model) {
/* 41 */     if (model.getUserId() == null)
/* 42 */       return AjaxResult.error("用户id不能为空"); 
/* 44 */     CrBondClue bondClue = new CrBondClue();
/* 45 */     BeanUtils.copyProperties(model, bondClue);
/* 46 */     bondClue.setCreateBy(model.getUserId().toString());
/* 47 */     bondClue.setCreateTime(new Date());
            bondClue.setBondCode("ZQXS"+new SimpleDateFormat("yyyyMMdd").format(new Date())+(int)((Math.random()*9+1)*1000));
///* 48 */     String address = "";
///* 49 */     if (StringUtils.isNotEmpty(model.getProvince()))
///* 50 */       address = address + model.getProvince();
///* 52 */     if (StringUtils.isNotEmpty(model.getCity()))
///* 53 */       address = address + model.getCity();
///* 55 */     if (StringUtils.isNotEmpty(model.getArea()))
///* 56 */       address = address + model.getArea();
///* 58 */     bondClue.setAddress(address+bondClue.getAddress());
/* 59 */     Integer i = Integer.valueOf(this.crBondClueService.insertCrBondClue(bondClue));
///* 60 */     if (i.intValue() > 0)
///* 62 */       if (StringUtils.isNotEmpty(model.getImage())) {
///* 63 */         List<String> imageList = Arrays.asList(model.getImage().split(","));
///* 64 */         for (String image : imageList) {
///* 65 */           CrEvidenceInfo info = new CrEvidenceInfo();
///* 66 */           info.setImage(image);
///* 67 */           info.setClueId(bondClue.getClueId());
///* 68 */           info.setType(Integer.valueOf(0));
///* 69 */           info.setCreateTime(new Date());
///* 70 */           this.evidenceInfoService.insertCrEvidenceInfo(info);
///*    */         }
///*    */       }
/* 74 */     return toAjax(i.intValue());
/*    */   }
/*    */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */ public AjaxResult editSave(CrBondClue crBondClue) {
            if (crBondClue.getClueId() == null)
            /* 42 */return AjaxResult.error("线索id不能为空");
        /* 147 */
        Integer i = Integer.valueOf(this.crBondClueService.updateCrBondClue(crBondClue));
        /* 148 */
    /* 171 */
        return toAjax(i.intValue());
    }
/*    */   @GetMapping({"/getList"})
/*    */   @ResponseBody
/*     */  @ApiOperation("搜索债权线索或交易列表")
@ApiImplicitParams({
        @ApiImplicitParam(name="province",value = "省",dataType = "字符串"),
        @ApiImplicitParam(name="city",value = "市",dataType = "字符串"),
        @ApiImplicitParam(name="area",value = "区",dataType = "字符串"),
        @ApiImplicitParam(name="approvalStatus",value = "审批状态 0待审批，1通过，2驳回",dataType = "数值"),
        @ApiImplicitParam(name="type",value = "类型 1线索，2交易",required = true,dataType = "数值"),
        @ApiImplicitParam(name="approvalStatus",value = "状态",dataType = "数值型")
})
/*    */   public AjaxResult getList(String province,String city,String area, Integer type,Integer approvalStatus) {
/* 84 */     Map<String, Object> paramMap = new HashMap<>();
/* 85 */     paramMap.put("province", province);
    /* 85 */ paramMap.put("city", city);
    /* 85 */ paramMap.put("area", area);
    /* 86 */ paramMap.put("type", type);
/* 87 */     paramMap.put("approvalStatus", 1);//审核通过
/* 88 */     startPage();
/* 89 */     List<CreditorRightsDto> creditorRightsDtoList = this.crBondClueService.selectList(paramMap);
/* 90 */     PageInfo info = new PageInfo(creditorRightsDtoList);
/* 91 */     return AjaxResult.success(info);
/*    */   }
/*    */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\lib\creditorRights-api-4.7.0.jar!\com\cr\api\controller\ApiBondClueController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */